Unable to move table cell

I have a pre-written script that syncs 2 modules together, moving objects from a Developmental version to a primary version.  The script runs fine if it is moving a normal object or if a table already exists in both versions.  However, if someone adds a table, the function crashes with the following error:

cannot move object: object is a table cell

I'm pretty sure the reason for the error is that the table, itself, hasn't been created yet, but besides that, I'm not sure how to fix the issue.  Here is the function in which the error occurs:

void promoteChildren(Object o) {
    Object oChild
    Object oChildPrevious
    int absNumChild = 0
    
    bool bHasChildren = false
    
    for oChild in o do {
        bHasChildren = true
        break;
    }
    
    if (bHasChildren) {
        oChild = first(o)
        move(oChild, o)
        absNumChild = oChild."Absolute Number"
        put(skConsequentialObjs, absNumChild, absNumChild)
        oChildPrevious = oChild
        
        while (true) {
            oChild = first(o)
            if (null oChild) break;
            move(oChild, oChildPrevious)
            absNumChild = oChild."Absolute Number"
            put(skConsequentialObjs, absNumChild, absNumChild)
            oChildPrevious = oChild
        }
    }
}

This function, as I'm told, is used if a heading has been deleted, but the objects below the heading remain.  It is supposed to promote those objects below the heading up a level so that the heading can then be deleted from the Primary version.  However, when it gets to a table, it drills down to the lowest level object (the cell of the table) and tries to move that object.


chrscote - Tue Oct 02 14:33:39 EDT 2018